import { createAsyncThunk } from "@reduxjs/toolkit";
import request from "../utils/request.js";
import axiosToken from "../utils/twoTokenRefresh.js";
export const getRouteList = createAsyncThunk("post/getRouteList", async () => {
  return request.post("/user/getRouteList");
});
export const testTokenLogin = createAsyncThunk(
  "post/testTokenLogin",
  async () => {
    return axiosToken.post("/user/login");
  },
);

export const getContent = createAsyncThunk("get/getContent", async (data) => {
  console.log(data, "ddddddddd=============");
  return request.get("/system/getContent", {
    params: data,
  });
});
export const postContent = createAsyncThunk(
  "post/postContent",
  async (data) => {
    return request.post("/system/postContent", data);
  },
);

export const getTableData = createAsyncThunk("post/getTableData", async () => {
  return {
    code: 200,
    message: "成功",
    data: [
      {
        name: "班级",
        age: 10,
      },
      {
        name: "你好",
        age: 10,
      },
    ],
  };
});
//样例

//get请求
export const getList = createAsyncThunk(
  "/getList" + "get/getList",
  async (data) => {
    return request.get("", {
      params: data,
    });
  },
);

//post请求
export const postList = createAsyncThunk(
  "/postList" + "post/postList",
  async (data) => {
    return request.post("", data);
  },
);

//下载文件  get
export const getDown = createAsyncThunk("get/getDown", async (data) => {
  request.downFile("/getDown", {
    method: "GET",
    params: data,
  });
});
//下载文件  post
export const postDown = createAsyncThunk("post/postDown", async (data) => {
  request.downFile("/getDown", {
    method: "POST",
    data: data,
  });
});
